package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.service.CourseService;
import com.zr.gdms.serviceimpl.CourseServiceImpl;

/**
 * @author  shichongming
 * @E-mail: 
 * @date 创建时间：2017年6月5日 下午6:01:19 
 * @version 1.0 
 * @parameter  
 * @since  
 * @return  
 */

public class AdminAuditingCourseSCM extends HttpServlet{
	CourseService cs=new CourseServiceImpl();
	
	
	//管理员审核课题
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
	
	doPost(req, resp);
}

@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		resp.setCharacterEncoding("utf-8");
		HttpSession session = req.getSession();
		int appid=Integer.parseInt(req.getParameter("appid"));
		String appcontent=req.getParameter("appcontent");
		int tid=Integer.parseInt(req.getParameter("tid"));
		String appstate="false";
		boolean flag=cs.sAuditingCourse(appid);		
		PrintWriter pw=resp.getWriter();
		if(flag){
			boolean flag1=cs.sAddAuditingCourse(appcontent, appstate, tid);	
			if(flag1){
				boolean flag2=cs.sDeleteAuditingCourse(appid);
				System.out.println(flag2);
				if(flag2){
					pw.write("1");
				}else{
					pw.write("0");
				}
			}else{
				pw.write("0");
			}			
		}else{
			pw.write("0");
		}				
		}
}
